package com.example.demo.mapper;

import com.example.demo.entity.AfoneshopChannel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-21
 */
@Mapper
public interface AfoneshopChannelMapper extends BaseMapper<AfoneshopChannel> {
    @Results(
            @Result( property = "ad_position_id", column = "adPositionId")
    )
    @Select("<script>" +
            "select * from AFoneshop_channel" +
            "        <if test='adPositionId != null and adPositionId != null'>" +
            "            and ad_position_id = #{adPositionId}" +
            "        </if> " +
            "        <choose>" +
            "            <when test='sidx != null and sidx.trim() != null'>" +
            "                order by ${sidx} ${order}" +
            "            </when>" +
            "            <otherwise> " +
            "                order by id desc" +
            "            </otherwise> " +
            "        </choose> " +
            "        <if test='offset != null and limit != null'>" +
            "            limit #{offset}, #{limit}" +
            "        </if>" +
            "</script>")
    List<AfoneshopChannel> queryList(Map<String, Object> map);
    @Select("select * from nideshop_channel where id = #{id}")
    AfoneshopChannel queryObject(Integer id);
    @Select("select count(*) from nideshop_channel")
    int queryTotal(Map<String, Object> map);
}
